function deepClone1(target) {
  return JSON.parse(JSON.stringify(target));
}


function deepClone2(target) {
  if (typeof target === "object" && target !== null) {
    let result = Array.isArray(target) ? [] : {};

    for (let key in target) {
      if (target.hasOwnProperty(key)) {
        result[key] = deepClone2(target[key]);
      }
    }
    return result;
  } else {
    return target;
  }
}

function deepClone3(target, map = new Map()) {
  if (typeof target === "object" && target !== null) {
    let cache = map.get(target);

    if (cache) {
      return cache;
    }

    let result = Array.isArray(target) ? [] : {};

    map.set(target, result);

    for (let key in target) {
      if (target.hasOwnProperty(key)) {
        result[key] = deepClone2(target[key], map);
      }
    }
    return result;
  } else {
    return target;
  }
}
